<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: 凡人
  Date: 2021/11/15
  Time: 10:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>列表</title>
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.2.1.js" rel="script"></script>
</head>
<body>
    <form action="./list">
        <input type="hidden" name="cur" id="cur">
        订单编号:<input type="text" name="orderId">
        <select name="field">
            <option value="">请选择</option>
            <option value="orderDate">订单日期</option>
            <option value="preparedDate">制单时间</option>
        </select>
        <input type="text" name="startDate"> 至
        <input type="text" name="endDate">
        <select name="field2">
            <option value="">请选择</option>
            <option value="rank">优先级</option>
            <option value="orderPrice">总金额</option>
        </select>
        <input type="text" name="start2"> 至
        <input type="text" name="end2"><br>
        <select name="field3">
            <option value="">请选择</option>
            <option value="client">客户名称</option>
            <option value="linkman">联系人</option>
            <option value="site">地址</option>
            <option value="tel">电话</option>
            <option value="preparedId">制单人编号</option>
            <option value="preparedBy">制单人</option>
        </select>
        <input type="text" name="msg">
        <input type="text" name="content">
        <input type="submit" value="搜索">
    </form>
    <a href="./toAdd">添加</a>
    <a href="javascript:void(0)" onclick="delAll()">批量删除</a>
<table class="table table-hover">
    <tr>
        <th></th>
        <th scope="col">序号</th>
        <th scope="col">订单日期</th>
        <th scope="col">订单编号</th>
        <th scope="col">客户名称</th>
        <th scope="col">优先级</th>
        <th scope="col">总金额</th>
        <th scope="col">备注</th>
        <th scope="col">联系人</th>
        <th scope="col">送货地址</th>
        <th scope="col">联系电话</th>
        <th scope="col">制单人工号</th>
        <th scope="col">制单人</th>
        <th scope="col">制单时间</th>
        <th scope="col">附件</th>
        <th scope="col">操作</th>
    </tr>
    <c:forEach var="i" items="${list.list}">
        <tr>
            <td>
                <input type="checkbox" class="ch" value="${i.id}">
            </td>
            <td>${i.id}</td>
            <td>
                <fmt:formatDate value="${i.orderDate}" pattern="yyyy-MM-dd"></fmt:formatDate>
            </td>
            <td>${i.orderId}</td>
            <td>${i.client}</td>
            <td>${i.rank}</td>
            <td>${i.orderPrice}</td>
            <td>${i.content}</td>
            <td>${i.linkman}</td>
            <td>${i.site}</td>
            <td>${i.tel}</td>
            <td>${i.preparedId}</td>
            <td>${i.preparedBy}</td>
            <td>
                <fmt:formatDate value="${i.preparedDate}" pattern="yyyy-MM-dd"></fmt:formatDate>
            </td>
            <td>
                <img src="${i.image}" width="50px" height="50px">
            </td>
            <td>
                <a href="./toDetail">详情</a>
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="100">
            <jsp:include page="/static/common/pages.jsp"></jsp:include>
        </td>
    </tr>
</table>
</body>
<script>
    function goPage(cur){
        $("#cur").val(cur);
        $("form").submit();
    }
    function delAll(){
        var str = "";
        $(".ch:checked").each(function(){
            str += "," + $(this).val();
        })
        str = str.substring(1);
        toDelete(str);
    }
    function toDelete(id){
        if(confirm("确定删除id为"+id+"的数据吗")){
            $.post("toDelete",{id:id},function(msg){
                if(msg == "ok"){
                    location.reload();
                }
            })
        }
    }
</script>
</html>
